// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // »Project« Talina Gaming System (TgS) (∂) // »File« TgS Common - Base - Type [IO].h // »Author« Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com) // »Version« 4.0 // ------------------------------------------------------------------------------------------------------------------------------ // // Copyright: © 2002-2010, Andrew Aye. All Rights Reserved. // This software is free for non-commercial use. Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. // Redistributions in binary form must reproduce this copyright notice, this list of conditions and the following // disclaimers in the documentation and other materials provided with the distribution. // Neither the names of the copyright owner nor the names of its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // The intellectual property rights of the algorithms used reside with Andrew Aye. You may not use this software, in whole or // in part, in support of any commercial product without the express written consent of the author. // There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is". // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // #if !defined(_TGS_COMMON_BASE_TYPE_IO_H_) #define _TGS_COMMON_BASE_TYPE_IO_H_ #pragma once // START TGS /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ============================================================================================================================== // // -- STg2_Input ---------------------------------------------------------------------------------------------------------------- // TgTYPE_DECLARE( struct STg2_Input, STg2_Input ); struct STg2_Input { // Read up to parameter bytes, return bytes read. TgSINT32 (*m_pfnRead)( PC_STg2_Input, PC_TgUINT08, C_TgSINT32 ); // Reposition the file pointer/position. TgSINT32 (*m_pfnSeek)( PC_STg2_Input, C_ETgIO_SEEK, C_TgSINT32 ); // Tests to see if input is complete TgBOOL (*m_pfnEnd_Of_File)( PC_STg2_Input ); }; TgINLINE TgVOID tgIO_Read_Line( PC_STg2_Input, PC_TgCHAR, C_TgUINT32 ); TgSINT32 tgIO_ScanF( PC_STg2_Input, CPC_TgCHAR, ... ); // ============================================================================================================================== // // -- STg2_Output --------------------------------------------------------------------------------------------------------------- // TgTYPE_DECLARE( struct STg2_Output, STg2_Output ); struct STg2_Output { // Writes out a consecutive count of bytes TgSINT32 (*m_pfnWrite)( PC_STg2_Output, CPC_TgUINT08, C_TgSINT32 ); // Reposition the file pointer/position. TgSINT32 (*m_pfnSeek)( PC_STg2_Output, C_ETgIO_SEEK, C_TgSINT32 ); }; TgINLINE TgSINT32 tgIO_Print( PC_STg2_Output, CPC_TgCHAR ); TgINLINE TgSINT32 tgIO_PrintF( PC_STg2_Output, CPC_TgCHAR, ... ); // ============================================================================================================================== // // -- STg2_Input_MEM ------------------------------------------------------------------------------------------------------------ // typedef struct { STg2_Input m_tgInput; TgSINT32 m_iSize; //« Maximum size of the input buffer TgSINT32 m_iPos; //« Current memory position CP_TgUINT08 m_pbyData; //« Memory buffer bound to this instantiation TgFCN_MEM_FREE m_pfnFree; } STg2_Input_MEM; TgTYPE_PREFIX( STg2_Input_MEM ); // 1: Pointer to the output structure to be initialized // 2: Pointer to the data buffer // 3: Size of the data buffer // 4: Pointer to a freeing function for the buffer. NULL is valid. TgINLINE TgVOID tgIO_IM_Open( PC_STg2_Input_MEM, CPC_TgUINT08, C_TgSINT32, TgFCN_MEM_FREE ); TgINLINE TgVOID tgIO_IM_Close( PC_STg2_Input_MEM ); TgINLINE TgSINT32 tgIO_IM_Size( PC_STg2_Input_MEM ); TgINLINE TgSINT32 tgIO_IM_Read( PC_STg2_Input, PC_TgUINT08, C_TgSINT32 ); TgINLINE TgSINT32 tgIO_IM_Seek( PC_STg2_Input, C_ETgIO_SEEK, C_TgSINT32 ); TgINLINE TgBOOL tgIO_IM_End_Of_File( PC_STg2_Input ); // ============================================================================================================================== // // -- STg2_Output_MEM ----------------------------------------------------------------------------------------------------------- // typedef struct { STg2_Output m_tgOutput; TgSINT32 m_iSize; //« Maximum size of the output buffer TgSINT32 m_iPos; //« Current memory position P_TgUINT08 m_pbyData; //« Memory buffer bound to this instantiation TgFCN_MEM_FREE m_pfnFree; } STg2_Output_MEM; TgTYPE_PREFIX( STg2_Output_MEM ); // 1: Pointer to the output structure to be initialized // 2: Pointer to the data buffer // 3: Size of the data buffer // 4: Pointer to a freeing function for the buffer. NULL is valid. TgINLINE TgVOID tgIO_OM_Open( PC_STg2_Output_MEM, PC_TgUINT08, C_TgSINT32, TgFCN_MEM_FREE ); TgINLINE TgVOID tgIO_OM_Close( PC_STg2_Output_MEM ); TgINLINE CP_TgUINT08 tgIO_OM_Query_Data( PC_STg2_Output_MEM ); TgINLINE TgSINT32 tgIO_OM_Write( PC_STg2_Output, CPC_TgUINT08, C_TgSINT32 ); TgINLINE TgSINT32 tgIO_OM_Seek( PC_STg2_Output, C_ETgIO_SEEK, C_TgSINT32 ); #endif // END ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////